#include<algorithm>
#include<cstdio>
#include<assert.h>
#include<vector>
#define pb push_back
#define ll long long
#define MaxN 100500
using namespace std;
vector<int> g[MaxN];
ll a[MaxN],f[MaxN],c[MaxN];
bool fl;
void dfs(int u,int fa)
{
  if (g[u].size()==1){
    c[u]=f[u]=a[u];
    return ;
  }
  ll s=0,mx=0;c[u]=0;
  for (int i=0,v;i<g[u].size();i++)
    if ((v=g[u][i])!=fa){
      dfs(v,u);
      s+=f[v];
      c[u]+=c[v];
      mx=max(mx,f[v]);
    }
  f[u]=2*a[u]-s;
  if (f[u]<0||s<0||f[u]>c[u]||(s-f[u])/2>s-mx)fl=0;
  if (!fa&&f[u]>0)fl=0;
}
int n;
void solve()
{
  scanf("%d",&n);
  for (int i=1;i<=n;i++){
    g[i].clear();
    scanf("%lld",&a[i]);
    assert(a[i]<=1000000000);
  }
  for (int i=1,u,v;i<n;i++){
    scanf("%d%d",&u,&v);
    g[u].pb(v);g[v].pb(u);
  }
  if (n==2){
    puts(a[1]==a[2] ? "YES" : "NO");
    return ;
  }
  int rt=0;
  for (int i=1;i<=n;i++)
    if (g[i].size()>1)rt=i;
  fl=1;dfs(rt,0);
  puts(fl ? "YES" : "NO");
}
int main()
{
  freopen("clean.in","r",stdin);
  freopen("clean.out","w",stdout);
  int T;scanf("%d",&T);
  while(T--)solve();
  return 0;
}
